import axios from "../axios";
//风险概况
export const alarm = json => {
  return axios({
    url: `/app/alarm/alarm?userName=${json.userName}`,
    method: "get"
  });
};
//风险概况 列表
export const alarmList = json => {
  return axios({
    url: "/app/alarm/alarmList",
    method: "post",
    data: json
  });
};
//获取报警详情
export const getdetaillist = json => {
  return axios({
    url: "/app/alarm/alarmDetailList",
    method: "post",
    data: json
  });
};
//获取地图
export const getmap = json => {
  return axios({
    url: "/app/alarm/getAllAlarmXYZ",
    method: "post",
    data: json
  });
};
// 地图 反馈
export const feedback = json => {
  return axios({
    url: "/app/alarm/saveAlarmFellBack",
    method: "post",
    data: json
  });
};

// 地图 获取反馈结果
export const feedbackresult = json => {
  return axios({
    url: `/app/alarm/getAlarmFellBack?alarmId=${json.alarmId}`,
    method: "get"
  });
};

// 地图 获取反馈历史记录
export const historyList = json => {
  return axios({
    url: `/app/alarm/historyList?alarmId=${json.alarmId}&equipmentId=${json.equipmentId}`,
    method: "get"
  });
}; 

// 预警处置
export const alarmdeal = json => {
  return axios({
    url: "/app/alarm/saveAlarmDealType",
    method: "post",
    data: json
  });
};
// 获取 曲线数据
export const getalarmTrend = json =>  {
  var urls = `/app/alarm/getalarmTrend?pipepointid=${json.pipepointid}`
  if(json.timeSelect){
    urls =urls+'&timeSelect='+`${json.timeSelect}`
  }
  if(json.startTime){
    urls = urls + `&startTime=${json.startTime}` + `&endTime=${json.endTime}`
  }
  return axios({
    url: urls,
    method: "get",
  });
}; 
// 登录
export const login = json => {
  var urls = "/app/alarm/appLogin"
  if(json.userName){
    urls =urls+'?userName='+`${json.userName}`
  }
  if(json.password){
    urls = urls + `&password=${json.password}`
  }
  return axios({
    url: urls,
    method: "post",
    data: json
  });
};
// 报告数据
export const report = json => {
  return axios({
    url: `/app/alarm/appReportObjects.mvc?type=${json.type}`,
    method: "get"
  });
};
export const downloadReport = json => {
  return axios({
    url: `/attachment/download/${json.fileid}.mvc`,
    method: "get"
  });
};
 
export const stateChange = json => {
  var urls = "/app/alarm/appBiogasAlarmStateChange"
  if(json.userName){
    urls =urls+'?userName='+`${json.userName}`
  }
  if(json.alarmId){
    urls = urls + `&alarmId=${json.alarmId}`
  }
  if(json.userId){
    urls = urls + `&userId=${json.userId}`
  }
  return axios({
    url: urls,
    method: "post",
    data: json
  });
};
//流程处置
export const getProcess = json => {
  return axios({
    url: `/alarmFlowController/alarmFlowList?alarmid=${json}`,
    method: "get"
  });
};

//历史数据；列表
export const alarmHistoryList = json => {
  return axios({
    url: "/app/alarm/alarmHistoryList",
    method: "post",
    data: json
  });
};

//附件查询
export const getFtpFile = json => {
  return axios({
    url: `/alarmFlowController/getFtpFile/${json}`,
    method: "get",
  });
};

export const uploadImg = json => {
  return axios({
    headers: { "Content-Type": "multipart/form-data" },
    url: `/app/alarm/uploadDealFile`,
    method: "post",
    data:json
  });
};

